Page({
  data: {
		isQiang:false,

		isEnd:false,

		shopArr:[
			{
				w:180,
				h:216,
				t:130,
				l:20,
				id:574576989687
			},
			{
				w:184,
				h:211,
				t:134,
				l:238,
				id:527036337530
			},
			{
				w:174,
				h:245,
				t:120,
				l:450,
				id:527050980299
			},
			{
				w:164,
				h:218,
				t:390,
				l:42,
				id:527036505839
			},
			{
				w:160,
				h:234,
				t:366,
				l:254,
				id:527048328080
			},
			{
				w:186,
				h:238,
				t:367,
				l:450,
				id:527049104768
			}
			

		]
	},

	//回到首页
	backMain(){
		my.reLaunch({
			url: '../index/index'
		});
	},
	
	seeShop(e){
		
		my.tb.openDetail ({
      itemId: e.target.dataset.id.toString(),
      success: (res) => {
        // my.alert({ content: "success" });
      },
      fail: (res) => {
        // my.alert({ content: "fail - " + res.error });
      },
		});

	},

	obtainMinePrize(){
		getApp().cloud.function.invoke('draw',{},"myPrizeLogList").then(res => {
			console.log(res); 
		})  
	},

	//开始游戏前判断剩余游戏次数是否充足
	startGame(){
		my.showLoading();
		getApp().cloud.function.invoke('client',{},"getCurrentUserInfo").then(res => {
			console.log('获取剩余游戏次数=====>',res); 

			my.hideLoading();

			if(res.data.game_left_num <= 0){
				this.setData({
					isEnd:'gameNo'
				})
			}else{
				my.navigateTo({
					url: '../game/game'
				});
			}
		})
		
		
	},

	onShow(query){

		

		this.server()
		this.obtainMinePrize()
	},
	onLoad(query) {
		
		this.setData({
			isEnd:query.end
		})
		
		this.server()
		this.obtainMinePrize()
	},
	
	async server(){
		let timer = await my.getServerTime()
		
		var time = new Date(timer.time);
		var y = time.getFullYear();
		var m = time.getMonth()+1;
		var d = time.getDate();
		

		//判断如果是 2021年3月4号 之后就是抢购
		if(y == 2021 && m == 3 && d>= 5){
			this.setData({
				isQiang:true
			})
		}else{
			this.setData({
				isQiang:false
			})
		}
		
	},

	getTask(){
		my.redirectTo({
			url: '../task/task'
		});
	},
});
